package com.luyu.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.luyu.entity.RolePermission;
import com.luyu.mapper.RolePermissionMapper;
import com.luyu.service.RolePermissionService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper, RolePermission> implements RolePermissionService {


    @Override
    public List<Long> listRoleIdsByPermissionIds(Long permissionId) {
        return this.lambdaQuery().eq(RolePermission::getPermissionId, permissionId).list().stream()
                .map(RolePermission::getRoleId)
                .collect(Collectors.toList());
    }
}
